﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Couple.Controls.CoupleDetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:customControls="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure"
    mc:Ignorable="d">
    <UserControl.Resources>
        <converters:NullableBoolToOppositeBoolConverter x:Key="boolToOppositeBool" />
        <converters:BoolToVisibilityCollapsedConverter x:Key="visibilityConverter" />
        
        <Style x:Key="ProtectedIdentityCheckBox" TargetType="{x:Type CheckBox}">
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>


    <Grid HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="161" />
            <RowDefinition Height="Auto" MinHeight="151" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <GroupBox x:Name="GroupBoxPerson1" Header="Person1, kontaktperson om ej ombud anges" Grid.RowSpan="3" Margin="5,5,5,10">

            <Grid Margin="0,10,0,0" HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Label Content="Folkbokförd i Sverige:" Grid.Row="0" Grid.Column="0" />

                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" >
                    <customControls:ExtendedRadioButton x:Name="rbMembershipPerson1Yes" Content="Ja" GroupName="MemberShipPerson1" Padding="5,0,0,0" Margin="0,0,10,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding Person1SwedishNationality, Mode=TwoWay}" />

                    <customControls:ExtendedRadioButton x:Name="rbMembershipPerson1No" Content="Nej" GroupName="MemberShipPerson1" Padding="5,0,0,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding Person1SwedishNationality, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" />

                </StackPanel>


                <TextBox x:Name="Person1NationalityTextBox" Grid.Row="0" Grid.Column="2"
                         Text="{Binding Person1Nationality, Mode=TwoWay}"
                         Visibility="{Binding Path=IsChecked, ElementName=rbMembershipPerson1Yes, Converter={StaticResource visibilityConverter}, Mode=TwoWay}" MaxLength="50"/>

                <Label Content="Kön:" Grid.Row="1" Grid.Column="0" />

                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" >
                    <customControls:ExtendedRadioButton x:Name="rbPerson1Female" Content="Kvinna" IsCheckedReal="{Binding Person1SexMale, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" 
                                 GroupName="Person1Sex" Padding="5,0,0,0" Margin="0,0,10,0" VerticalAlignment="Center" />
                    <customControls:ExtendedRadioButton x:Name="rbPerson1Male" Content="Man" IsCheckedReal="{Binding Person1SexMale, Mode=TwoWay}" GroupName="Person1Sex" Padding="5,0,0,0" 
                                 VerticalAlignment="Center" />
                </StackPanel>

                <Label Content="Födelsedatum:" Grid.Row="2" Grid.Column="0" />

                <TextBox x:Name="Person1PersonalNumberTextBox" ToolTip="ÅÅÅÅMMDD-XXXX" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" MaxLength="13" Width="100"
                         Text="{Binding Person1PersonalNumber, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />

                <CheckBox x:Name="Person1ProtectedIdentityCheckBox" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" Margin="5,0,0,0" Padding="5,0,0,0"
                          Content="Skyddade personuppgifter" IsChecked="{Binding Person1ProtectedIdentity, Mode=TwoWay}" 
                          Checked="Person1ProtectedIdentityCheckBox_Checked" Unchecked="Person1ProtectedIdentityCheckBox_Checked" >
                </CheckBox>

                <Label Content="Förnamn:" Grid.Row="3" Grid.Column="0" />
                <Label Content="Efternamn:" Grid.Row="4" Grid.Column="0" />
                <Label Content="C/o-adress:" Grid.Row="5" Grid.Column="0" />
                <Label Content="Adress:" Grid.Row="6" Grid.Column="0" />
                <Label Content="Postnummer:" Grid.Row="7" Grid.Column="0" />
                <Label Content="Postort:" Grid.Row="8" Grid.Column="0" />
                <Label Content="Land:" Grid.Row="9" Grid.Column="0" />

                <TextBox x:Name="Person1FirstNamesTextBox" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding Person1FirstNames, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="300" />

                <TextBox x:Name="Person1LastNameTextBox"  Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding Person1LastName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="70" MaxWidth="300" />

                <TextBox x:Name="CoAddressTextBox"  Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding CoAddress, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="150" MaxWidth="300" />

                <TextBox x:Name="StreetAddressTextBox"  Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding StreetAddress, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="150" MaxWidth="300" />

                <TextBox x:Name="ZipCodeTextBox"  Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding ZipCode, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="10" />

                <TextBox x:Name="CityTextBox"  Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="2" 
                                 Text="{Binding City, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="100" MaxWidth="300" />

                <TextBox x:Name="NationalityTextBox"  Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding Country, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" />

            </Grid>

        </GroupBox>
        <GroupBox x:Name="GroupBoxPerson2" Header="Person2" Grid.Column="1" Margin="5,5,5,0" Height="160" VerticalAlignment="Top">

            <Grid Margin="0,10,0,0" HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Label Content="Folkbokförd i Sverige:" Grid.Row="0" Grid.Column="0" />

                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" >
                    <customControls:ExtendedRadioButton x:Name="rbMembershipPerson2Yes" Content="Ja" GroupName="MemberShipPerson2" Padding="5,0,0,0" Margin="0,0,10,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding Person2SwedishNationality, Mode=TwoWay}" />

                    <customControls:ExtendedRadioButton x:Name="rbMembershipPerson2No" Content="Nej" GroupName="MemberShipPerson2" Padding="5,0,0,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding Person2SwedishNationality, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" />

                </StackPanel>

                <TextBox x:Name="Person2NationalityTextBox" Grid.Row="0" Grid.Column="2"
                         Text="{Binding Person2Nationality, Mode=TwoWay}"
                         Visibility="{Binding Path=IsChecked, ElementName=rbMembershipPerson2Yes, PresentationTraceSources.TraceLevel=High, Converter={StaticResource visibilityConverter}, Mode=TwoWay}" MaxLength="50" />

                <Label Content="Kön:" Grid.Row="1" Grid.Column="0" />

                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" >
                    <customControls:ExtendedRadioButton x:Name="rbPerson2Female" Content="Kvinna" IsCheckedReal="{Binding Person2SexMale, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" 
                                 GroupName="Person2Sex" Padding="5,0,0,0" Margin="0,0,10,0" VerticalAlignment="Center" />
                    <customControls:ExtendedRadioButton x:Name="rbPerson2Male" Content="Man" IsCheckedReal="{Binding Person2SexMale, Mode=TwoWay}" GroupName="Person2Sex" Padding="5,0,0,0" 
                                 VerticalAlignment="Center" />
                </StackPanel>                

                <Label Content="Födelsedatum:" Grid.Row="2" Grid.Column="0" />
                
                <TextBox x:Name="Person2PersonalNumberTextBox" ToolTip="ÅÅÅÅMMDD-XXXX" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" MaxLength="13" Width="100"
                         Text="{Binding Person2PersonalNumber, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />
                
                <CheckBox x:Name="Person2ProtectedIdentityCheckBox" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" Margin="5,0,0,0" Padding="5,0,0,0"
                          Content="Skyddade personuppgifter" IsChecked="{Binding Person2ProtectedIdentity}" 
                          Checked="Person2ProtectedIdentityCheckBox_Checked" Unchecked="Person2ProtectedIdentityCheckBox_Checked">
                </CheckBox>

                <Label Content="Förnamn:" Grid.Row="3" Grid.Column="0" />
                <Label Content="Efternamn:" Grid.Row="4" Grid.Column="0" />

                <TextBox x:Name="Person2FirstNamesTextBox" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding Person2FirstNames, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="300" />

                <TextBox x:Name="Person2LastNameTextBox"  Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2"
                                 Text="{Binding Person2LastName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="70" MaxWidth="300" />
            </Grid>

        </GroupBox>
        <GroupBox x:Name="GroupBoxContactPerson" Header="Kontaktinformation" Grid.Column="1" Grid.Row="1" Margin="5,5,5,10">

            <Grid Margin="0,10,0,0" HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="2">
                    <customControls:ExtendedRadioButton x:Name="RadioButtonPerson1" Content="Person1" GroupName="ContactPerson" Margin="0,0,10,0" 
                                 IsCheckedReal="{Binding Person1IsContact, Mode=TwoWay}" Checked="RadioButtonContact_Checked" />
                    <customControls:ExtendedRadioButton x:Name="RadioButtonOtherPerson" Content="Annan person" GroupName="ContactPerson" Checked="RadioButtonContact_Checked" 
                                 IsCheckedReal="{Binding Person1IsContact, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" />
                </StackPanel>

                <Label Content="Förnamn:" Grid.Row="1" Grid.Column="0" MinWidth="133"/>
                <Label Content="Efternamn:" Grid.Row="2" Grid.Column="0" />
                <Label Content="Telefon:" Grid.Row="3" Grid.Column="0" />
                <Label Content="E-postadress:" Grid.Row="4" Grid.Column="0" />

                <TextBox x:Name="ContactFirstNameTextBox" Grid.Row="1" Grid.Column="1" MinWidth="280"
                         Text="{Binding ContactPersonFirstName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="300" />

                <TextBox x:Name="ContactLastNameTextBox" Grid.Row="2" Grid.Column="1" 
                         Text="{Binding ContactPersonLastName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="70" MaxWidth="300" />

                <TextBox x:Name="PhoneTextBox" Grid.Row="3" Grid.Column="1" 
                         Text="{Binding Phone, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" MaxWidth="300" />

                <TextBox x:Name="EmailTextBox" Grid.Row="4" Grid.Column="1" 
                         Text="{Binding Email, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="300" />

            </Grid>

        </GroupBox>

        <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,5" VerticalAlignment="Bottom">
            <Button x:Name="ChangeButton" Content="Ändra" Click="ChangeButton_Click" Visibility="Hidden" />
            <Button x:Name="AddButton" Content="Ny registrering" Command="{Binding AddCommand}" Width="95" Margin="5,0,0,0" Click="AddButton_Click" />
            <Button x:Name="SaveButton" Content="Spara" Command="{Binding SaveCommand}" Margin="5,0,0,0" Click="SaveButton_Click" IsEnabled="True" />
        </StackPanel>
    </Grid>

</UserControl>
